#include <stdio.h>
#include <stdlib.h>

void next()
{
    char c[] = "_abaabcac";
    int i ,j;
    i = 1;
    j = 0;
    int next[9];
    next[1] = 0;
    while (i<9)
    {
        if(j==0||c[i]==c[j])
        {
            ++i;
            ++j;
            next[i] = j;
        }
        else{
            j=next[j];
        }
    }
    for (int k = 1; k < 9; k++)
    {
        printf("%3d",next[k]);
    }
}
void next_2(){
    
}

int main()
{
    /*******************code*******************/
    next();

    /******************************************/
    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
